﻿using UnityEngine;
using System.Collections;

public class health : MonoBehaviour {
    public int Health;
    private Animator animator;
	// Use this for initialization

	void Start () {
        animator = GetComponent<Animator>();  
	}
	
	// Update is called once per frame
	void Update () {
	
	}
    void Die() {
        animator.Play("die");
    }

    public void TakeDamage(int damage)
    {
        //由攻击者调用被攻击者的收到伤害行为，传递伤害参数。伤害存储在攻击者.攻击部件.碰撞器中。
        Health -= damage;
        if (Health <= 0)
        {
            Die();
        }
        else
        {
            animator.Play("attacked");
        }
    }
}
